
* ************************************************************************** *;
* ************************************************************************** *;
* The Causes and Outcomes of Coup During Civil War                           *;
* (JCR Forthcoming)                                                          *; 
*                                                                            *; 
* Authors: Curtis Bell and Jun Koga Sudduth                                  *;
*                                                                            *; 
* Date: June 2015                                                            *;                                          
* ************************************************************************** *; 
* ************************************************************************** *; 
   
 
* Data 

use "C:\Users\Jun\Dropbox\Bell_Koga\Final JCR\Warcoup_Bell_Sudduth_JCR.dta", clear  


* *********************************************************** *;
* Descriptive Statistics (Table 2 & 3 & Appendix Table 8 & 9) *; 
* *********************************************************** *; 

*1.1 Descriptive Statistics 
tab acoup incid, col 
 
*1.2 Descriptive Statistics 
tab scoup incid if acoup==1, col 

* 1.3 Descriptive Statistics (Rebel capability )
tab acoup maxrebstr if incid==1, col

tab acoup maxfigcap if incid==1, col

* 1.4 Descriptive Statistics (Location )
tab acoup intown if incid==1, col
 
* create a new variable "per_ln_mindist"   
sum  mindist  ,detail 

gen per_mindist=1 if mindist==0
replace per_mindist=. if mindist==.
replace per_mindist=2 if mindist!=0 & mindist <  235
replace per_mindist= 3 if mindist >= 235 & mindist < 533
replace per_mindist= 4 if mindist >=  533  

  
tab acoup per_mindist if incid==1, col


 
   
  
* ********************************************************************** *; 
* Table 4  (Heckman Probit Model )                                       *:
* ********************************************************************** *; 

* Model 1 
heckprob scoup incid   gw_lrgdpch    acoupyr  acoupyr2 acoupyr3,robust cluster(ccode) sel(acoup=incid  gw_lrgdpch  democracy military acoupyr acoupyr2 acoupyr3) 
* Model 2  
heckprob scoup incid gw_lrgdpch  lsolpay     acoupyr  acoupyr2 acoupyr3,robust cluster(ccode) sel(acoup=incid gw_lrgdpch lsolpay democracy military acoupyr acoupyr2 acoupyr3) 
* Model 3 
heckprob scoup incid gw_lrgdpch  lsolpay   lmilper acoupyr  acoupyr2 acoupyr3,robust cluster(ccode) sel(acoup=incid gw_lrgdpch lsolpay lmilper democracy military acoupyr acoupyr2 acoupyr3) 
* Model 4 
heckprob scoup incid p_paramilitary  gw_lrgdpch lsolpay   lmilper   acoupyr  acoupyr2 acoupyr3,robust cluster(ccode) sel(acoup=incid  p_paramilitary gw_lrgdpch   lsolpay   lmilper  democracy military acoupyr acoupyr2 acoupyr3) 
* Model 5 
heckprob scoup incid p_counterbal gw_lrgdpch lsolpay   lmilper  acoupyr  acoupyr2 acoupyr3,robust cluster(ccode) sel(acoup=incid p_counterbal   gw_lrgdpch lsolpay   lmilper democracy military acoupyr acoupyr2 acoupyr3) 
   
 
 
  
  
* ******************************************* *; 
* Table 5  (Simulation First Difference)      *; 
* ******************************************* *;

* Coup attempts  
estsimp probit acoup incid gw_lrgdpch lsolpay lmilper democracy military acoupyr acoupyr2 acoupyr3, sims(10000) robust cluster(ccode) 
 
setx ( gw_lrgdpch lsolpay lmilper ) mean (democracy  military) median  acoupyr 17.42997  acoupyr2 303.80385 acoupyr3    5295.2921    incid  0
    
simqi 

setx ( gw_lrgdpch lsolpay lmilper) mean   (democracy  military) median  acoupyr 17.42997    acoupyr2 303.80385 acoupyr3    5295.2921    incid  1
    
simqi 

setx ( gw_lrgdpch lsolpay lmilper ) mean  (democracy  military) median  acoupyr 17.42997   acoupyr2 303.80385 acoupyr3    5295.2921   
    
simqi, fd(pr) changex(incid 0 1 ) level(99) 


* percentage difference

 display (    .0265806    -   .0146096  )/(    .0146096   )*100
 * 81.93927 % up
 
 
* Coup Success 

use "C:\Users\Jun\Dropbox\Bell_Koga\Final JCR\Warcoup_Bell_Sudduth_JCR.dta", clear  

heckprob scoup incid gw_lrgdpch  lsolpay   lmilper acoupyr  acoupyr2 acoupyr3,robust cluster(ccode) sel(acoup=incid gw_lrgdpch lsolpay lmilper democracy military acoupyr acoupyr2 acoupyr3) 
  
matrix params = e(b)
*Pulls the beta values for later calcualtions */

matrix P = e(V) 
*Pulls the variance matrix for later calculations */

collapse (mean)   gw_lrgdpch  lmilper lsolpay   acoupyr    (median)  democracy military
 
generate acoupyr2 = (acoupyr)^2 
generate acoupyr3 = acoupyr^3 



expand 10000

drawnorm beta1-beta18 rho, means(params) cov(P)
    *This command draws the betas and other parameters from the model, you must adjust this line of the total number of variabels in your model (including constants).   	 

sum rho beta*

correlate rho beta*, cov

gen simrho = (exp(2*rho)-1)/(exp(2*rho)+1)

* Set the variables : all means or medians except your key IV (civil war status) 
* Note that I will estimate the effect of civil war only on the outcome level. So I need to keep the exactly the same values for all variables
* in the selection models including the civil war status. (More precisely, I will have "civil war" as 1 in both of the selection modles. 
 

generate select1 =  beta18 + (beta17* acoupyr3) + (beta16 *acoupyr2) + (beta15* acoupyr ) + (beta14* military) + (beta13*democracy) + (beta12*lmilper) + (beta11* lsolpay) + (beta10*gw_lrgdpch) + (beta9*0)
   
generate outcome1 = beta8 +  (beta7 * acoupyr3) + (beta6 *acoupyr2) + (beta5*acoupyr) + (beta4 *lmilper) + (beta3*lsolpay) + (beta2* gw_lrgdpch ) + (beta1*0)
   
generate outcome2 = beta8 +  (beta7 * acoupyr3) + (beta6 *acoupyr2) + (beta5*acoupyr) + (beta4 *lmilper) + (beta3*lsolpay) + (beta2* gw_lrgdpch ) + (beta1*1)
  
 

generate conditionalp1 = binorm(outcome1, select1, simrho)/ normal(select1)

generate conditionalp2= binorm(outcome2, select1, simrho)/ normal(select1)

generate joinp1 = binorm(outcome1, select1, simrho)
generate joinp2= binorm(outcome2, select1, simrho)

generate fd_con= conditionalp2 - conditionalp1 

generate fd_j= joinp2 - joinp1 

* Table results 
 ci conditionalp1, level(95)  

 ci conditionalp2, level(95) 
 
 ci fd_con, level(99)


* Percentage change 
 
 display (.255898- .492425   )/(   .492425  )*100
 
 * -48.033101

 
 
 
  
* ********************************************************************* *; 
* Table 6 (Effect of civil war types on War-time Coup Attempts)         *; 
* ********************************************************************* *;  

use "C:\Users\Jun\Dropbox\Bell_Koga\Final JCR\Warcoup_Bell_Sudduth_JCR.dta", clear   

* Model 1 
logit acoup ln_mindist  maxfigcap  gw_lrgdpch lsolpay  lmilper  democracy  military  acoupyr  acoupyr2  acoupyr3    if incid==1, robust cluster(ccode)
* Model 2 
logit acoup ln_mindist  maxfigcap  gw_lrgdpch lsolpay  lmilper  democracy  military  acoupyr  acoupyr2  acoupyr3  lwarduration if incid==1, robust cluster(ccode)
* Model 3   
logit acoup intown  maxfigcap  gw_lrgdpch lsolpay  lmilper   democracy  military  acoupyr  acoupyr2  acoupyr3   if incid==1, robust cluster(ccode)
* Model 4   
logit acoup intown  maxfigcap  gw_lrgdpch lsolpay  lmilper   democracy  military  acoupyr  acoupyr2  acoupyr3  lwarduration   if incid==1, robust cluster(ccode)
* Model 5 
logit acoup  ln_mindist maxrebstr   gw_lrgdpch   lsolpay  lmilper  democracy   military acoupyr  acoupyr2  acoupyr3    if incid==1, robust cluster(ccode)
* Model 6 
logit acoup ln_mindist maxrebstr   gw_lrgdpch  lsolpay  lmilper  democracy   military acoupyr  acoupyr2  acoupyr3  lwarduration  if incid==1, robust cluster(ccode)
* Model 7   
logit acoup  intown maxrebstr gw_lrgdpch  lsolpay  lmilper  democracy   military acoupyr  acoupyr2  acoupyr3      if incid==1, robust cluster(ccode)
* Model 8  
logit acoup  intown maxrebstr gw_lrgdpch  lsolpay  lmilper  democracy   military acoupyr  acoupyr2  acoupyr3   lwarduration  if incid==1, robust cluster(ccode)

  
 
* ****************************** *; 
* Table 7                        *; 
* ****************************** *;

** Effect of Maxfigcap (Fighting Capacity) 
* Predicted probability of coup attempt 
 
estsimp logit acoup ln_mindist  maxfigcap  gw_lrgdpch lsolpay  lmilper  democracy  military  acoupyr  acoupyr2  acoupyr3    if incid==1, sims(10000) robust cluster(ccode)

setx ( gw_lrgdpch lsolpay lmilper ln_mindist  ) mean  maxfigcap 1     (democracy  military) median   acoupyr 17.42997  acoupyr2 303.80385 acoupyr3    5295.2921      
simqi 
 
setx ( gw_lrgdpch lsolpay lmilper ln_mindist  ) mean  maxfigcap 2     (democracy  military) median   acoupyr 17.42997  acoupyr2 303.80385 acoupyr3    5295.2921      
simqi 

setx ( gw_lrgdpch lsolpay lmilper ln_mindist  ) mean  maxfigcap 3  (democracy  military) median    acoupyr 17.42997  acoupyr2 303.80385 acoupyr3    5295.2921      
simqi   

 
* First difference 
setx ( gw_lrgdpch lsolpay lmilper ln_mindist  ) mean  maxfigcap 1 (democracy  military) median  acoupyr 17.42997  acoupyr2 303.80385 acoupyr3    5295.2921      
simqi, fd(pr) changex( maxfigcap 1  3 ) level(99) 

display   (.0982539  -.0373895  )/(.0373895)*100

*162.78474 %
 

setx ( gw_lrgdpch lsolpay lmilper ln_mindist  ) mean  maxfigcap 1 (democracy  military) median  acoupyr 17.42997  acoupyr2 303.80385 acoupyr3    5295.2921      
simqi, fd(pr) changex( maxfigcap 1 2) level(99) 

display (.0604083-.0373895  )/(.0373895)*100
*61.564878

setx ( gw_lrgdpch lsolpay lmilper ln_mindist  ) mean  maxfigcap 1 (democracy  military) median  acoupyr 17.42997  acoupyr2 303.80385 acoupyr3    5295.2921      
simqi, fd(pr) changex( maxfigcap 2 3) level(99) 


display  (.0982539 -.0604083)/(.0604083) *100 
* 62.649669



** Effect of Maxrebstr (Rebel General Strength)  
* Predicted probability of coup attempt 
drop b*

estsimp logit acoup ln_mindist maxrebstr  gw_lrgdpch lsolpay  lmilper  democracy  military  acoupyr  acoupyr2  acoupyr3    if incid==1, sims(10000) robust cluster(ccode)

setx ( gw_lrgdpch lsolpay lmilper ln_mindist  ) mean maxrebstr  1 (democracy  military) median  acoupyr 17.42997  acoupyr2 303.80385 acoupyr3    5295.2921      
simqi 
 

setx ( gw_lrgdpch lsolpay lmilper ln_mindist  ) mean maxrebstr  3   (democracy  military) median  acoupyr 17.42997  acoupyr2 303.80385 acoupyr3    5295.2921      
simqi 
 
setx ( gw_lrgdpch lsolpay lmilper ln_mindist  ) mean maxrebstr  5   (democracy  military) median    acoupyr 17.42997  acoupyr2 303.80385 acoupyr3    5295.2921      
simqi 
 
 
* First difference 

setx ( gw_lrgdpch lsolpay lmilper ln_mindist  ) mean maxrebstr  1  (democracy  military) median  acoupyr 17.42997  acoupyr2 303.80385 acoupyr3    5295.2921      
simqi, fd(pr) changex(  maxrebstr 1  5 ) level(90) 

display (.1046903 -  .0366653  )/( .0366653  )*100
*185.52964 %

setx ( gw_lrgdpch lsolpay lmilper ln_mindist  ) mean maxrebstr  1   (democracy  military) median  acoupyr 17.42997  acoupyr2 303.80385 acoupyr3    5295.2921      
simqi, fd(pr) changex(  maxrebstr 1  3 ) level(90) 

display (.0605435-  .0366653  )/( .0366653  )*100
*65.124791 %


setx ( gw_lrgdpch lsolpay lmilper ln_mindist  ) mean maxrebstr  1   (democracy  military) median   acoupyr 17.42997  acoupyr2 303.80385 acoupyr3    5295.2921      
simqi, fd(pr) changex(  maxrebstr 3 5 ) level(90) 

display (.1046903 -.0605435)/(.0605435)*100
*72.917489




** Effect of ln_mindist (distance) : 
*Predicted probability of coup attempt 

drop b*
estsimp logit acoup ln_mindist  maxfigcap  gw_lrgdpch lsolpay  lmilper  democracy  military  acoupyr  acoupyr2  acoupyr3    if incid==1, sims(10000) robust cluster(ccode)

sum ln_mindist, detail

setx ( gw_lrgdpch lsolpay lmilper   ) mean  ln_mindist 5.312783 maxfigcap median     (democracy  military) median  acoupyr 17.42997  acoupyr2 303.80385 acoupyr3    5295.2921      
simqi 
 
setx ( gw_lrgdpch lsolpay lmilper   ) mean  ln_mindist 5.312783+1.60123 maxfigcap median     (democracy  military) median  acoupyr 17.42997  acoupyr2 303.80385 acoupyr3    5295.2921      
simqi 
 
 
setx ( gw_lrgdpch lsolpay lmilper   ) mean  ln_mindist p10 maxfigcap median   (democracy  military) median   acoupyr 17.42997  acoupyr2 303.80385 acoupyr3    5295.2921      
simqi 
 

setx ( gw_lrgdpch lsolpay lmilper   ) mean  ln_mindist p90 maxfigcap median   (democracy  military) median   acoupyr 17.42997  acoupyr2 303.80385 acoupyr3    5295.2921      
simqi 
 

 
* First difference 
* mean -> mean+sd 
setx ( gw_lrgdpch lsolpay lmilper   ) mean  ln_mindist 5.312783 maxfigcap median   (democracy  military) median   acoupyr 17.42997  acoupyr2 303.80385 acoupyr3    5295.2921        
simqi, fd(pr) changex(  ln_mindist 5.312783   5.312783+1.60123      ) level(99) 

display ( .0306022  - .0381452)/( .0381452)*100

*-19.774441 %
* 

setx ( gw_lrgdpch lsolpay lmilper   ) mean  ln_mindist 5.312783 maxfigcap median   (democracy  military) median  acoupyr 17.42997  acoupyr2 303.80385 acoupyr3    5295.2921        
simqi, fd(pr) changex(  ln_mindist p10 p90     ) level(99) 


display (.0298181 -.0440033    )/(.0440033) *100 

* -32.236673 % 
 



** Effect of "Intown" 
* Predicted Probaiblity 

drop b*
estsimp logit acoup intown maxfigcap  gw_lrgdpch lsolpay  lmilper  democracy  military  acoupyr  acoupyr2  acoupyr3    if incid==1, sims(10000) robust cluster(ccode)

setx ( gw_lrgdpch lsolpay lmilper   ) mean  intown 1  maxfigcap median    (democracy  military) median  acoupyr 17.42997  acoupyr2 303.80385 acoupyr3    5295.2921      
simqi 
 
setx ( gw_lrgdpch lsolpay lmilper   ) mean  intown 0  maxfigcap median   (democracy  military) median  acoupyr 17.42997  acoupyr2 303.80385 acoupyr3    5295.2921      
simqi 

 
* First difference 
* mean -> mean+sd 
 
setx ( gw_lrgdpch lsolpay lmilper   ) mean  intown 0  maxfigcap median  (democracy  military) median  acoupyr 17.42997  acoupyr2 303.80385 acoupyr3    5295.2921      
simqi, fd(pr) changex(  intown 0  1   ) level(95) 

display   (.0768786 - .0360431 )/(.0360431 )*100

*113.2963 %


  
  
   



* END   *;
